#include "timer.h"

void set_timer_freq(uint8_t cntl_w, uint16_t data)
{
	outb(cntl_w, (uint16_t)CONTROL_WORD_PORT);						//Write control message to counter.
	outb((uint8_t)(data&0xff), (uint16_t)COUNTER_0_PORT);			//Write low bits data to counter.
	outb((uint8_t)((data>>8)&0xff), (uint16_t)COUNTER_0_PORT);		//Write high bits data to counter.

}

void timer_init()
{
	uint8_t cntl_w = (uint8_t)(CNT0<<6|LOCK_FOR_CPU<<4|WAY2<<1|BIN);
	uint16_t timer_init_data = 11932;
	set_timer_freq(cntl_w, timer_init_data);
}